package com.tongji.seller.view.popup
{
	import com.tongji.seller.events.utilsEvent.BrightEvent;
	
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	
	import mx.managers.PopUpManager;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 *
	 * @author caddy
	 * @date 2012-2-3
	 */
	public class BrightTitleWinMediator extends Mediator
	{
		[Inject]
		public var view:BrightTitleWindow;
		public var bright:ColorTransform;
		override public function onRegister():void
		{
			eventMap.mapListener(view.setBrightBtn, MouseEvent.CLICK, setBrightHandler, MouseEvent);
			eventMap.mapListener(view.cancle, MouseEvent.CLICK, cancleHandler, MouseEvent);
			eventMap.mapListener(view.closeButton, MouseEvent.CLICK, cancleHandler, MouseEvent);

			addViewListener(BrightEvent.SET_BRIGHT, dispatch);
		}
		
		private function setBrightHandler(event:MouseEvent):void
		{
			bright = new ColorTransform(1, 1, 1, 1, view.sliderBrightness.value, view.sliderBrightness.value, view.sliderBrightness.value, 0);
			dispatch(new BrightEvent(BrightEvent.SET_BRIGHT, bright));
			PopUpManager.removePopUp(view);
		}
		
		/**
		 * @author caddy 
		 * @param event
		 * 取消亮度设置，还原为之前的状态
		 */		
		private function cancleHandler(event:MouseEvent):void
		{
			//dispatch(new FilterEvent(FilterEvent.SET_FILTER, view.dropShadow));
			PopUpManager.removePopUp(view);
		}
	}
}